﻿using System;

namespace EOrm.NpgsqlProvider
{
    /// <summary>
    /// postgres数据库构建类
    /// </summary>
    public class PgDbFactory : IDbFactory
    {
        /// <summary>
        /// 数据库构建
        /// </summary>
        /// <returns>数据库接口</returns>
        public Db Create()
        {
            return Create("");
        }

        /// <summary>
        /// 数据库构建
        /// </summary>
        /// <param name="jsonConfigPathOrConString">配置文件或连接字符串</param>
        /// <returns>数据库接口</returns>
        public Db Create(string jsonConfigPathOrConString)
        {
            if (jsonConfigPathOrConString == null || string.IsNullOrEmpty(jsonConfigPathOrConString.Trim()))
            {
                jsonConfigPathOrConString = AppDomain.CurrentDomain.BaseDirectory + "Config\\DbConfig.json";
            }
            return PgDb.CreateInstance(jsonConfigPathOrConString);
        }
    }
}
